OBJS=bsp.o mrfi.o nwk_api.o nwk.o nwk_frame.o nwk_globals.o nwk_join.o \
nwk_link.o nwk_ioctl.o nwk_QMgmt.o nwk_freq.o nwk_ping.o \
nwk_mgmt.o nwk_security.o

BSP_PATH=./Components/bsp
MRFI_PATH=./Components/mrfi
NWK_PATH=./Components/simpliciti/nwk
NWK_APP_PATH=./Components/simpliciti/nwk_applications
INCLUDES=-I$(MRFI_PATH) -I$(NWK_PATH) -I$(NWK_APP_PATH) -I$(BSP_PATH) -I$(BSP_PATH)/boards/CC430EM -I$(BSP_PATH)/drivers
RADIO=MRFI_CC430

CC=msp430-gcc
CFLAGS=-Os -g -mmcu=cc430f6137 $(INCLUDES) -D$(RADIO) -DSIZE_INFRAME_Q=6 -DSIZE_OUTFRAME_Q=2 -DTHIS_DEVICE_ADDRESS="{{0x97, 0x56, 0x34, 0x12}}" -DMAX_HOPS_FROM_AP=2 -DDEFAULT_LINK_TOKEN=0x05060708 -DDEFAULT_JOIN_TOKEN=0x01020304 -DMAX_HOPS=3 -DMAX_APP_PAYLOAD=10 -DSIZE_INFRAME_Q=6 -DMAX_NWK_PAYLOAD=MAX_PING_APP_FRAME -DNUM_CONNECTIONS=8 -DEND_DEVICE

all: RTS

%.o: %.c
	$(CC) $(CFLAGS) -c $<
		
bsp.o: $(BSP_PATH)/bsp.c
	$(CC) $(CFLAGS) -c $< -o $@
	@echo CC $<
	
mrfi.o: $(MRFI_PATH)/mrfi.c nwk_frame.o
	$(CC) $(CFLAGS) -c $< -o $@
	@echo CC $<
	
nwk_security.o: $(NWK_APP_PATH)/nwk_security.c
	$(CC) $(CFLAGS) -c $< -o $@
	@echo CC $<
	
nwk_mgmt.o: $(NWK_APP_PATH)/nwk_mgmt.c
	$(CC) $(CFLAGS) -c $< -o $@
	@echo CC $<

nwk_ping.o: $(NWK_APP_PATH)/nwk_ping.c
	$(CC) $(CFLAGS) -c $< -o $@
	@echo CC $<
	
nwk_freq.o: $(NWK_APP_PATH)/nwk_freq.c
	$(CC) $(CFLAGS) -c $< -o $@
	@echo CC $<
	
nwk_QMgmt.o: $(NWK_PATH)/nwk_QMgmt.c
	$(CC) $(CFLAGS) -c $< -o $@
	@echo CC $<
	
nwk_ioctl.o: $(NWK_APP_PATH)/nwk_ioctl.c
	$(CC) $(CFLAGS) -c $< -o $@
	@echo CC $<
	
nwk_link.o: $(NWK_APP_PATH)/nwk_link.c
	$(CC) $(CFLAGS) -c $< -o $@
	@echo CC $<

nwk_join.o: $(NWK_APP_PATH)/nwk_join.c
	$(CC) $(CFLAGS) -c $< -o $@
	@echo CC $<
	
nwk_frame.o: $(NWK_PATH)/nwk_frame.c nwk.o nwk_api.o
	$(CC) $(CFLAGS) -c $< -o $@
	@echo CC $<
	
nwk_globals.o: $(NWK_PATH)/nwk_globals.c
	$(CC) $(CFLAGS) -c $< -o $@
	@echo CC $<
	
nwk_api.o: $(NWK_PATH)/nwk_api.c nwk.o 
	$(CC) $(CFLAGS) -c $< -o $@
	@echo CC $<

nwk.o: $(NWK_PATH)/nwk.c
	$(CC) $(CFLAGS) -c $< -o $@
	@echo CC $<
	
RTS: RTSmain.c $(OBJS)
	$(CC) $(CFLAGS) -o RTS.elf RTSmain.c $(OBJS)
	
clean:
	rm -fr RTS.elf $(OBJS)
